#include "transfer_serial_port.h"

CTransferCom::CTransferCom()
{

}
CTransferCom::~CTransferCom()
{

}
int CTransferCom::Open(const char* dev_name, int parm1, int parm2)
{
	int ret = 0;
	/*
	BaudRate::BaudRate9600
	Parity::ParityNone
	DataBits::DataBits8
	StopBits::StopOne
	FlowControl::FlowNone
	*/
	printf("dev %s BaudRate %d .\n", dev_name, parm1);

	m_com.init(dev_name,
		BaudRate(parm1),
		Parity::ParityNone,
		DataBits::DataBits8,
		StopBits::StopOne,
		FlowControl::FlowNone);
	bool bRet = 0;
	
	bRet = m_com.open();
	
	if (!bRet)
	{
		printf("CTransferCom::Open fail errno %d .\n",errno);
		return -1;
	}
	printf("CTransferCom::Open %s ok.\n", dev_name);
	return 0;
}

void CTransferCom::Close()
{
	m_com.close();
}

int CTransferCom::ReadData(unsigned char* data, int buf_sz)
{
	int ret = m_com.readData((char*)data,buf_sz);
	return ret;
}

int  CTransferCom::SendData(unsigned char* data, int buf_sz)
{
	int ret = m_com.writeData((char*)data, buf_sz);
	return ret;
}

void CTransferCom::SetDebugMod(int mode)
{
	m_com.setDebugModel(mode);
}
